<?php

require("./config.php");

if (!isset($_POST['req'])) {
    die("No request provided.");
}else {
    if (filter_input(INPUT_POST, 'req') == "registroUsuario") {
        $json = array("success" => false, "msg" => "", "user" => "", "pss" => "");       
        
            $usuario = $dbConn->real_escape_string(filter_input(INPUT_POST, 'usuario'));
            $email = $dbConn->real_escape_string(filter_input(INPUT_POST, 'email'));
            $password = $dbConn->real_escape_string(filter_input(INPUT_POST, 'password'));
         
            
         
            
            $query = "insert into usuariocliente values('" . $email . "', '" 
                    . $usuario . "', '". $password."');";
            $result = $dbConn->query($query);

               if ($result != null) {           

                $json["succes"] = true;
                $json["msg"] = "Se ha registrado correctamente.";
                $json["user"] = $usuario;
                $json["pss"] = $password;
               }
            
        print(json_encode($json));
    } 
}